home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_02
/
9n02030a
< prev
next >
Wrap
Text File
|
1990-12-11
|
862b
|
31 lines
void
QuickSort( int *List, int Begin, int End )
{
int Value, Tmp, i, j;
if( End > Begin )
{
/* Divide the list in two */
Value = List[End];
i = Begin - 1;
j = End;
do {
while( List[++i] < Value );
while( List[--j] > Value );
Tmp = List[i];
List[i] = List[j];
List[j] = Tmp;
} while( j > i );
List[j] = List[i];
List[i] = List[End];
List[End] = Tmp;
/* Sort the first part */
QuickSort( List, Begin, i - 1 );
/* Sort the last part */
QuickSort( List, i + 1, End );
}
}